<?php
/**
 * Ticket Model.
 * @package    spf.modules.tickets
 * @author     Simon Downes <simon@simondownes.co.uk>
 * @copyright  Copyright &copy; 2007, Simon Downes 
 * @license    http://www.opensource.org/licenses/mit-license.php
 */

/**
 * Ticket Model.
 *
 * @package    spf.modules.tickets
 * @author     Simon Downes <simon@simondownes.co.uk>
 * @copyright  Copyright &copy; 2007, Simon Downes 
 * @license    http://www.opensource.org/licenses/mit-license.php
 */
final class Milestone extends SPF_Model {

   /**
    * Constructor.
    *
    * @return  void
    */
   public function __construct() {

      /* construct the parent object */
      parent::__construct('milestones');
      
      $this->add_validation('description', true, 'alphanumeric', ' ');
      
   } // __construct

   /**
    * Destructor.
    *
    * @return  void
    */
   public function __destruct() {
      parent::__destruct();
   }
   
   public function clear( $keep_id = false ) {
       
       parent::clear($keep_id);
       
       $this->active = 1;
       
   } // clear
   
   public function after_delete( $args ) {
      
      // clear milestone_id on any tickets assigned to this milestone
      $sql = "UPDATE tickets
                 SET milestone_id = 0
               WHERE milestone_id = ?";
      $this->db->execute($sql, $args);
      
   } // after_delete
   
} // Milestone

?>
